﻿using Universities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace UniversityTests
{
    [TestClass]
    public class StudentTest
    {
        [TestMethod]
        public void StudentConstructorTest()
        {
            string name = "Marin";
            int fn = 61131;
            Student target = new Student(name, fn);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void StudentConstructorNullNameTest()
        {
            string name = null;
            int fn = 61131;
            Student target = new Student(name, fn);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void StudentConstructorEmptyNameTest()
        {
            string name = string.Empty;
            int fn = 61131;
            Student target = new Student(name, fn);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void StudentConstructorTooSmallFNTest()
        {
            string name = "Marin";
            int fn = 9999;
            Student target = new Student(name, fn);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void StudentConstructorTooLargeFNTest()
        {
            string name = "Marin";
            int fn = 100000;
            Student target = new Student(name, fn);
        }

        [TestMethod]
        public void EqualsFalseTest()
        {
            string name = "Marin";
            int fn = 61131;
            Student target = new Student(name, fn);
            object obj = 5;
            bool expected = false;
            bool actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void EqualsTrueTest()
        {
            string name = "Marin";
            int fn = 61131;
            Student target = new Student(name, fn);
            object obj = new Student(name, fn);
            bool expected = true;
            bool actual = target.Equals(obj);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetHashCodeTest()
        {
            string name = "Marin";
            int fn = 61131;
            Student target = new Student(name, fn);
            int expected = fn.GetHashCode();
            int actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void FnTest()
        {
            string name = "Marin";
            int fn = 61133;
            Student target = new Student(name, fn);
            int expected = 61131;
            int actual;
            target.Fn = expected;
            actual = target.Fn;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void NameTest()
        {
            string name = "Anonymous";
            int fn = 61131;
            Student target = new Student(name, fn);
            string expected = "Marin";
            string actual;
            target.Name = expected;
            actual = target.Name;
            Assert.AreEqual(expected, actual);
        }
    }
}
